<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/3/21
 * Time: 17:12
 */

namespace Home\Controller;
use Think\Controller;

class SearchController extends Controller
{
    public function cat_search() {

        $catId = I('get.cat_id');
        $goodsModel = D('Admin/Goods');
        $data = $goodsModel->cat_search($catId);

        $catModel = D('Admin/Category');
        $searchFilter = $catModel->getSearchConditionByGoodsId($data['goods_id']);



        $this->assign(array(
            'page' => $data['page'],
            'data' => $data['data'],
            'searchFilter' => $searchFilter,
            '_page_title'  => '分类搜索页',
            '_page_keywords'  => '分类搜索页',
            '_page_description'  => '分类搜索页',
        ));
        $this->display();
    }

    public function key_search(){
        $key = I('get.key');
        $goodsModel = D('Admin/Goods');
        $data = $goodsModel->key_search($key);

        //根据上面搜索出来的商品计算筛选条件
        $catModel = D('Admin/Category');
        $searchFilter = $catModel->getSearchConditionByGoodsId($data['goods_id']);


        $this->assign(array(
            'page' => $data['page'],
            'data' => $data['data'],
            'searchFilter' => $searchFilter,
            '_page_title' => '关键字搜索页',
            '_page_keywords' => '关键字搜索页',
            '_page_description' => '关键字搜索页',
        ));
        $this->display();
    }

}